<?php
	global $SSO, $Security, $AppID, $User, $DB;
	//Check to see if there is a valid session 
	$SessionInfo = $SSO->isValidSession("index.php?action=login", $SSO->getSessionInformation());	
		
	//Check to see if the user has rights to be on LivingWeb
	$PageRights = array('ADMIN','USER');
	$UserRoles = $Security->ValidateUser($SessionInfo['username'], $AppID, $PageRights, 1);
	
	//Grab the user info
	$UserInfo = $User->GetUserInfo($SessionInfo['username']);	

	global $DB,$PageServer;
	$thePID = $PageServer->GetNewPID();

	$db_string = $DB->compile_db_insert_string( 
	array (
		'PageID'		=> $thePID,
		'MinistryID'		=> $_GET['MID'],
		'CreatedDate'    		=> date("Y-m-d H:i:s"),
		'CreatedBy'		=> $SessionInfo['username'])
		);
	
	$DB->query("INSERT INTO pages (".$db_string['FIELD_NAMES'].") VALUES (".$db_string['FIELD_VALUES'].")");

	$db_string = $DB->compile_db_insert_string( 
	array (
		'PageID'		=> $thePID,
		'ContentOrder'		=> '1')
		);
	
	$DB->query("INSERT INTO page_content (".$db_string['FIELD_NAMES'].") VALUES (".$db_string['FIELD_VALUES'].")");
	
	header("Location: index.php?action=edit&edit_action=edit_props&PID=" . $thePID);
?>
 
 
